import 'package:flutter/cupertino.dart';

//扩展方法
extension Intfit on int {
  double get px {
    return ScreenHelper.getpx(toDouble());
  }
}

extension Doublefit on double {
  double get px {
    return ScreenHelper.getpx(toDouble());
  }
}

class ScreenHelper {
  //一些参数:获取与保存屏幕大小
  static double radio = 1;
  static double? screenWidth;
  static double? screenHeigth;
  static MediaQueryData? mediaData;

  static init(BuildContext context, {double baseSize = 375}) {
    mediaData = MediaQuery.of(context);
    screenHeigth = mediaData?.size.height;
    screenWidth = mediaData?.size.width;
    radio = screenWidth! / baseSize;
  }

  static double getpx(double size) {
    return size * ScreenHelper.radio;
  }
}
